package welsir.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import welsir.entity.dos.Tag;
import welsir.entity.vo.ResultMessage;
import welsir.mapper.TagMapper;
import welsir.util.ResultUtil;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Genius
 * @date 2023/03/08 01:49
 **/
@Api(value = "web端tag")
@RestController
@RequestMapping("/webTag")
public class WebTagController {
    @Resource
    private TagMapper allTagMapper;

    @ApiOperation(value = "获取所有tag")
    @GetMapping("/getAllTag")
    public ResultMessage<List<Tag>> getAllTag(
    ) {
        return ResultUtil.data(allTagMapper.selectList(null));
    }

    @ApiOperation(value = "根据uid获取tag")
    @GetMapping("/getTagByList/{id}")
    public ResultMessage<Tag> getTagByList(
            @PathVariable("id") Integer id
    ) {
        QueryWrapper<Tag> wrapper = new QueryWrapper<>();
        wrapper.eq("id",id);
        return ResultUtil.data(allTagMapper.selectOne(wrapper));
    }
}
